package com.yanqu.road.server.cmd.activity.summerquiz.fromcross;

import com.yanqu.road.entity.log.summerquiz.LogSummerQuizGuess;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SummerQuizProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SUMMER_QUIZ_USER_GUESS_FROM_CROSS, desc = "竞猜(跨服返回)")
public class SummerQuizGuessActionFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        SummerQuizProto.CrossSummerQuizGuessActionRespMsg respMsg = SummerQuizProto.CrossSummerQuizGuessActionRespMsg.parseFrom(packet.getBytes());

//        player.getModule(PreReduceModule.class).restorePreReduce(respMsg.getConsume());
//
        player.sendPacket(Protocol.U_SUMMER_QUIZ_USER_GUESS, respMsg.getClient().toBuilder());

        if(respMsg.getClient().getRet() == 0){
//            player.getModule(CurrencyModule.class).removeCurrency(PropertyHelper.parseStringToProperty(respMsg.getConsume()), eLogMoneyType.SummerQuizActivity, eLogMoneyType.SummerQuizActivityGuessConsume);
            //日志
            AutoLogMgr.add(new LogSummerQuizGuess(
                    respMsg.getActivityId(),
                    respMsg.getGameActivityId(),
                    packet.getPlayerId(),
                    respMsg.getTitleId(),
                    respMsg.getSelectId()
            ));
        }

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
